package com.cn.txx.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.cn.txx.dao.zydao.SjzNdMapper;
import com.cn.txx.dao.zydao.SjzTimeMapper;
import com.cn.txx.dao.zydao.UserMapper;
import com.cn.txx.entity.SjzNd;
import com.cn.txx.entity.SjzTime;
import com.cn.txx.entity.User;
import com.cn.txx.service.LoginService;

@Service
public class LoginServiceImp implements LoginService{

	private Logger logegr = Logger.getLogger(this.getClass());
	
	@Resource
	private UserMapper userMapper;
	@Resource
	private SjzNdMapper sjzNdMapper;
	@Resource
	private SjzTimeMapper sjzTimeMapper;
	
	
	@Override
	//@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
	public User queryUserById(String id) {
		return userMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<SjzNd> getSjzData() {
		List<SjzNd> allSjzNd = null;
		try {
			allSjzNd = sjzNdMapper.getAllSjzNd();
			for (SjzNd sjzNd : allSjzNd) {
				 List<SjzTime> allTime = sjzTimeMapper.getAllTime(sjzNd.getNd());
				 sjzNd.setSjzList(allTime);
			}
		} catch (Exception e) {
			logegr.error("查询时间轴数据错误...",e);
		}
		
		return allSjzNd;
	}

}
